home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best of Shareware
/
Best of PC Windows Shareware 1.0 - Wayzata Technology (7111) (1993).iso
/
mac
/
WINDOWS
/
MISCUTIL
/
MSGBAR10
/
SOURCE.EXE
/
SAMPLE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-29
|
7KB
|
227 lines
/*****************************************************************************
* FILE: SAMPLE.C
* PURPOSE: Sample appliction showing the use of the Message Bar
* Copyright 1992-1993 Paul King, All rights reserved.
* Revision History:
* Date Name Description
---- ---- -----------
* 12/29/92 Paul King Original version
*****************************************************************************/
#define STRICT
#include <windows.h>
#include "sample.h"
//Header file for Message Bar functions
#include "mb.h"
//Prototypes
LPARAM FAR PASCAL MainDlgProc(HWND, UINT, WPARAM, LPARAM);
//Global variables
HINSTANCE hInst;
HMENU hMenu;
//Internal Definitions
#define GREY RGB (192, 192, 192)
#define WHITE RGB (0, 0, 0)
/*****************************************************************************
* Funciton: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
* Purpose: Application entry point
*****************************************************************************/
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,
LPSTR lpszCmdLine, int nCmdShow)
{
static char szAppName[] = "MessageBar";
HWND hWnd;
MSG msg;
WNDCLASS wc;
hInst = hInstance;
if (!hPrevInst)
{
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) MainDlgProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInst;
wc.hIcon = LoadIcon (hInst, szAppName);
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
wc.lpszMenuName = szAppName;
wc.lpszClassName = szAppName;
RegisterClass (&wc);
}
//Load the Menu
hMenu = LoadMenu (hInst, szAppName);
hWnd = CreateWindow (szAppName, "Sample Application",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
hMenu, hInst, NULL);
ShowWindow (hWnd, nCmdShow);
UpdateWindow (hWnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
/*****************************************************************************
* Function: MainDlgProc(HWND, UINT, WPARAM, LPARAM)
* Purpose: Application callback function
*****************************************************************************/
LPARAM FAR PASCAL MainDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
LPARAM lParam)
{
static BOOL bMessageBar;
BOOL bState;
switch (msg)
{
case WM_CREATE:
//Init the Message Bar
bMessageBar = InitMB (hDlg, hInst, GREY, WHITE, TRUE);
return TRUE;
case WM_CTLCOLOR:
//Needed to color our message bar
return ColorMB (wParam, lParam);
case WM_SIZE:
//Needed to resize the message bar
ResizeMB();
break;
case WM_MENUSELECT:
//Display some help text to the user in the status bar
if ((LOWORD (lParam) == -1) && (HIWORD (lParam) == 0))
//User left the menu. Clear the message text
MBText ("");
else
{
switch (LOWORD (lParam) & (MF_POPUP | MF_SYSMENU))
{
case 0:
//wParam is a menu ID from a nonsystem menu
//Make sure it is not a separator
if (wParam)
switch ((int) wParam)
{
case IDM_EXIT:
MBText ("Terminate this application");
break;
case IDM_MBAR:
MBText ("Turn the Message Bar ON or OFF");
break;
case IDM_JUNK1:
MBText ("Bogus Message 1");
break;
case IDM_JUNK2:
MBText ("Bogus Message 2");
break;
case IDM_JUNK3:
MBText ("Bogus Message 3");
break;
}
else
MBText ("");
break;
case MF_POPUP:
//wParam is handle to a nonsystem popup menu
MBText ("");
break;
case MF_SYSMENU:
//wParam is a menu ID from the system menu
MBText ("");
break;
case MF_POPUP | MF_SYSMENU:
//wParam is the handle to the system menu
MBText ("");
break;
}
}
break;
case WM_COMMAND:
switch (wParam)
{
case IDM_EXIT:
DestroyWindow (hDlg);
break;
case IDM_MBAR:
bState = GetMenuState (hMenu, IDM_MBAR,
MF_BYCOMMAND) & MF_CHECKED;
//Turn the Message Bar ON or OFF
MBShow (!bState);
//Toggle menuitem
CheckMenuItem (hMenu, IDM_MBAR, MF_BYCOMMAND |
(bState ? MF_UNCHECKED : MF_CHECKED));
break;
}
return FALSE;
case WM_CLOSE:
DestroyWindow (hDlg);
return FALSE;
case WM_DESTROY:
//If our Message bar was created, delete it
if (bMessageBar)
KillMB ();
PostQuitMessage (0);
return FALSE;
}
return DefWindowProc (hDlg, msg, wParam, lParam);
}